#include "WStlTest.h"
#include <iostream>
#include <typeinfo>

WStlTest::WStlTest()
{

}

WStlTest::~WStlTest()
{

}

void WStlTest::WListTest()
{
    WList<int> testList;

    testList.push_back(14);
    testList.push_front(16);
    testList.push_back(19);
    testList.push_back(10);
    testList.push_back(12);

    cout << "start show list value: ";
    for (WList<int>::iterator it = testList.begin(); it != testList.end(); ++it)
    {
        cout << *it << " ";
    }
    cout << endl;


    int value;
    testList.pop_back(value);
    cout << "start show list value after pop_back: ";
    for (WList<int>::iterator it = testList.begin(); it != testList.end(); ++it)
    {
        cout << *it << " ";
    }
    cout << endl;

    testList.pop_front(value);
    cout << "start show list value after pop_front: ";
    for (WList<int>::iterator it = testList.begin(); it != testList.end(); ++it)
    {
        cout << *it << " ";
    }
    cout << endl;

    auto it1 = testList.begin() + 2;
    cout << "*it1 is " << *it1 << endl;

    People p1;
    p1.age = 18;
    p1.name = "wenyuean";
    WList<People> peopleList;
    peopleList.push_back(p1);
    auto peopleIt = peopleList.begin();

    cout << "peopleIt->name: " << peopleIt->name << endl;
}

void WStlTest::WTypeTraitsTest()
{
    WList<int> intList;
    // WList<int>::iterator::valueType value2 = 100;
    IteratorTraits<WList<int>::iterator>::valueType value1 = 100;
    cout << "IteratorTraits<WList<int>::iterator> type is " << typeid (value1).name() << endl;

    WVector<int> intVec;
    IteratorTraits<WVector<int>::iterator>::valueType value2 = 100;
    cout << "IteratorTraits<WVector<int>::iterator> type is " << typeid (value2).name() << endl;
}

void WStlTest::WMapTest()
{
    WMap<int, string> wMapTest;
    wMapTest[10] = "hello10";
    wMapTest[3] = "hello3";
    wMapTest[16] = "hello16";
    wMapTest[8] = "8";
    wMapTest[8] = "hello8";
    wMapTest[20] = "hello20";
    // wMapTest.insert(20, "hello20");
    cout << "wMapTest size: " << wMapTest.size() << endl;
    // wMapTest.erase(3);
    for (auto it = wMapTest.begin(); it != wMapTest.end(); ++it)
    {
        cout << "key: " << it->first << ", value: " << it->second << endl;
        //cout << "key: " << (*it).first << ", value: " << (*it).second << endl;
    }
}
